import 'package:file_picker/file_picker.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'package:get/get.dart';
import 'package:jiffy/jiffy.dart';
import 'package:safetymonitor/app/components/custom_app_bar.dart';
import 'package:safetymonitor/app/components/custom_date_type.dart';
import 'package:safetymonitor/app/components/custom_modele/custom_file_upload_page.dart';
import 'package:safetymonitor/app/components/custom_modele/custom_high_input_page.dart';
import 'package:safetymonitor/app/components/custom_modele/custom_input_page.dart';
import 'package:safetymonitor/app/components/custom_modele/custom_select_page.dart';
import 'package:safetymonitor/app/components/custom_modele/custom_title_chart_page.dart';
import 'package:safetymonitor/app/components/custom_multi_choice_checkbox/CustomCheckbox.dart';
import 'package:safetymonitor/app/components/custom_multi_choice_checkbox/CustomTwoChoiceCheckbox.dart';
import 'package:safetymonitor/app/components/custom_title_content_view.dart';
import 'package:safetymonitor/app/components/toast_widget.dart';
import 'package:safetymonitor/app/core/core.dart';
import 'package:safetymonitor/app/core/env/env.dart';
import 'package:safetymonitor/app/core/ext/widget_extension.dart';
import 'package:safetymonitor/app/core/utils/user_manager.dart';
import 'package:safetymonitor/app/data/entities/home/duty/system_user_page_entity.dart';
import 'package:safetymonitor/router/app_pages.dart';

import 'controller.dart';

///处置（红色和橙色）
class RedDisposePage extends StatelessWidget {
  RedDisposePage({super.key});

  final controller = Get.put(DisposeController());

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: AppColors.bg_color_grey,
      appBar: CustomAppBar(
        titleText: controller.tittle(),
      ),
      body: GetBuilder(
        init: controller,
        builder: (_) {
          return SingleChildScrollView(
              child: controller.entity.click != 11 //只有查看权限
                  ? Column(
                children: [
                  AppGaps.vGap10,
                  _getStateView(),
                  Obx(() {
                    return controller.currentIndex.value == 0
                        ? _getNormalView() // 基本信息
                        : _getExistenceView();
                  }),
                ],
              )
                  : _getNormalView() // 基本信息,
          );
        },
      ),
    );
  }

  Widget _getNormalView() {
    return Column(children: [
      _titleBg(),
      CustomTitleChartPage(
        contentPadding: EdgeInsets.only(right: 16.w, left: 16.w, top: 16.w),
        title: controller.entity.companyName,
        titleRightWidget: controller.listController.getStatueView(controller.entity.status),
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.start,
          children: [
            Row(
              children: [
                Expanded(child: _getTextView(title: '点位:', value: controller.entity.deviceCode)),
                Expanded(
                  child: _getTextView(
                    title:'${CustomDateType.getDataType(controller.entity.dataType)}级别:',
                    value: CustomDateType.getAlarmType(controller.entity.alarmLevel, controller.entity.dataType),
                  ),
                )
              ],
            ),
            Row(
              children: [
                Expanded(
                  child: _getTextView(
                    title: '系统-类别:',
                    value: controller.entity.categoryZh,
                  ),
                ),
                Expanded(child: _getTextView(title: '${CustomDateType.getDataType(controller.entity.dataType)}数值:', value: '${controller.entity.val}')),
              ],
            ),
            Row(
              children: [
                Expanded(child: _getTextView(title: '系统名称:', value: controller.entity.systemName)),
                Expanded(child: _getTextView(title: '监测类型:', value: controller.entity.categoryZh
                    .split('-')
                    .last)),
              ],
            ),
            _getTextView(
                title: '${CustomDateType.getDataType(controller.entity.dataType)}开始:', value: controller.entity.alarmStartTime != 0 ? Jiffy.parseFromMillisecondsSinceEpoch(controller.entity.alarmStartTime).format(pattern: 'yyyy-MM-dd HH:mm:ss') : ''),
            _getTextView(
                title: '${CustomDateType.getDataType(controller.entity.dataType)}结束:',
                value: controller.entity.alarmEndTime != 0 ? Jiffy.parseFromMillisecondsSinceEpoch(controller.entity.alarmEndTime).format(pattern: 'yyyy-MM-dd HH:mm:ss') : ''),
            // _getTextView(title: '报警结束:', value: DateTime.now().toStr),
            AppGaps.vGap6,
          ],
        ),
      ),
      Visibility(
        visible: controller.getDistributeReturnRecordListEntity.returnList.isNotEmpty,
        child: Column(children: [
          _titleBg(),
          Container(
            height: 40.w,
            width: double.infinity,
            color: const Color(0xFFF4F7FF),
            alignment: Alignment.centerLeft,
            padding: EdgeInsets.only(left: 40.w),
            child: Text(
              '退回信息',
              style: TextStyle(
                fontSize: 16.sp,
              ),
            ),
          ),
          Container(
            height: 1.w,
            color: const Color(0xFFDEE5FD),
          ),
          Container(
            color: Colors.white,
            padding: EdgeInsets.only(left: 20.w, right: 20.w, top: 20.w, bottom: 20.w),
            child: Column(
              children: controller.getDistributeReturnRecordListEntity.returnList.map((e) {
                return Column(
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: [
                    _rowData('${_actionType(e.actionType)}退回人：', e.actionUserName),
                    AppGaps.vGap5,
                    _rowData('退回原因：', '${e.alarmDesc ?? ''}'),
                    AppGaps.vGap10,
                  ],
                );
              }).toList(),
            ),
          ),
        ],),
      ),
      Visibility(
        visible: controller.getDistributeReturnRecordListEntity.distributeList.isNotEmpty,
        child: Column(
          children: [
            _titleBg(),
            Container(
              height: 40.w,
              width: double.infinity,
              color: const Color(0xFFF4F7FF),
              alignment: Alignment.centerLeft,
              padding: EdgeInsets.only(left: 40.w),
              child: Text(
                '处置信息',
                style: TextStyle(
                  fontSize: 16.sp,
                ),
              ),
            ),
            Container(
              height: 1.w,
              color: const Color(0xFFDEE5FD),
            ),
            Column(
              children: controller.getDistributeReturnRecordListEntity.distributeList.map((e) {
                return Container(
                  margin: EdgeInsets.only(bottom: 15.w),
                  child: CustomTitleContentView(
                    // titleEdgeInsets: EdgeInsets.only(left: 20.w, top: 15.w),
                    // 提示信息
                    title: Container(
                      color: Colors.white,
                      padding: EdgeInsets.only(left: 8.w, right: 8.w, top: 9.w, bottom: 20.w),
                      child: Column(
                        crossAxisAlignment: CrossAxisAlignment.start,
                        children: [
                          _rowData( '${CustomDateType.getDataType(controller.entity.dataType)}原因：' , e.alarmDisposalRecordDO.reasonType),
                          AppGaps.vGap10,
                          _rowData('${CustomDateType.getDataType(controller.entity.dataType)}描述：', e.alarmDisposalRecordDO.reasonAnalysis),
                          AppGaps.vGap10,
                          _rowData('现场处理人：', e.alarmDisposalRecordDO.sceneDisposalPersonName),
                          AppGaps.vGap10,
                          _rowData('所属部门：', e.alarmDisposalRecordDO.ascriptionDeptName),
                          AppGaps.vGap10,
                          _rowData('现场处理时间：',e.alarmDisposalRecordDO.sceneDisposalTime!=0?Jiffy.parseFromMillisecondsSinceEpoch(e.alarmDisposalRecordDO.sceneDisposalTime).format(pattern: 'yyyy-MM-dd HH:mm:ss'):''),
                          AppGaps.vGap12,
                          _rowData('负责人：', e.alarmDisposalRecordDO.undertakePersonName),
                          AppGaps.vGap12,
                          _rowData('处置措施：', e.alarmDisposalRecordDO.disposalMeasures),
                          AppGaps.vGap12,
                          // _rowData('处置附件：', e.alarmDisposalRecordDO.disposalMeasuresAnnex),
                          // AppGaps.vGap12,
                          // _getBottomView(),
                          CustomFileUploadPage(
                            isRequired: false,
                            isShowDivider: false,
                            isEnabled: false,
                            isChange: false,
                            uploadedFiles: e.alarmDisposalRecordDO.disposalMeasuresAnnex.isNotEmpty ? e.alarmDisposalRecordDO.disposalMeasuresAnnex.split(',') : [],
                            title: '附件：',
                            onCallBack: (value) {},
                          ),
                        ],
                      ),
                    ),
                    contentEdgeInsets: EdgeInsets.only(top: 10.w, bottom: 20.w),
                    content: Column(
                      children: e.distributeList.map((e) {
                        return Container(
                          color: Colors.white,
                          padding: EdgeInsets.only(left: 20.w, right: 20.w),
                          child: Column(
                            crossAxisAlignment: CrossAxisAlignment.start,
                            children: [
                              // _rowData('分公司验收', '${e.companyId}'),
                              // AppGaps.vGap5,
                              _rowData('处置结果：', _actionType(e.actionType), valueColor: _actionTypeC(e.actionType)),
                              AppGaps.vGap5,
                              _rowData('说明：', e.alarmDesc),
                              AppGaps.vGap5,
                            ],
                          ),
                        );
                      }).toList(),
                    ),
                    // Column(
                    //   children: [
                    //     Container(
                    //       color: Colors.white,
                    //       padding: EdgeInsets.only(left: 20.w, right: 20.w),
                    //       child: Column(
                    //         crossAxisAlignment: CrossAxisAlignment.start,
                    //         children: [
                    //           _rowData('分公司验收', ''),
                    //           AppGaps.vGap5,
                    //           _rowData('处置结果：', '处置合格', valueColor: const Color(0xFF17D484)),
                    //           AppGaps.vGap5,
                    //           _rowData('说明：', 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXX'),
                    //         ],
                    //       ),
                    //     ),
                    //     AppGaps.vGap10,
                    //     Container(
                    //       color: Colors.white,
                    //       padding: EdgeInsets.only(left: 20.w, right: 20.w),
                    //       child: Column(
                    //         crossAxisAlignment: CrossAxisAlignment.start,
                    //         children: [
                    //           _rowData('总公司验收', ''),
                    //           AppGaps.vGap5,
                    //           _rowData('处置结果：', '处置不合格', valueColor: const Color(0xFFFA6C6D)),
                    //           AppGaps.vGap5,
                    //           _rowData('说明：', 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXX'),
                    //         ],
                    //       ),
                    //     )
                    //   ],
                    // ),
                  ),
                );
              }).toList(),
            )
          ],
        ),
      )
    ]);
  }

  Widget _rowData(String name, String value, {Color valueColor = const Color(0xFF495061)}) {
    return Row(
      crossAxisAlignment: CrossAxisAlignment.start,
      children: [
        Text(
          name,
          style: TextStyle(
            color: const Color(0xFFA5A6B5),
            height: 1.2,
            fontWeight: FontWeight.w400,
            fontSize: 12.sp,
          ),
        ),
        Expanded(
            child: Text(
              value,
              style: TextStyle(
                color: valueColor,
                height: 1.2,
                fontSize: 12.sp,
                fontWeight: FontWeight.w400,
              ),
            )),
      ],
    );
  }

  /// 标题背景分隔栏
  Widget _titleBg() {
    return Column(
      children: [
        AppGaps.vGap12,
        Container(
          height: 2.w,
          color: const Color(0xFF587DF5),
        ),
      ],
    );
  }

  Widget _getExistenceView() {
    return Column(
      children: [
        _titleBg(),
        Container(
          color: Colors.white,
          padding: EdgeInsets.only(left: 20.w, right: 20.w, top: 20.w, bottom: 20.w),
          child: Column(
            crossAxisAlignment: CrossAxisAlignment.start,
            children: [
              _showView(),
              AppGaps.vGap20,
              Container(
                width: double.infinity,
                color: Colors.white,
                padding: EdgeInsets.symmetric(horizontal: 5.w, vertical: 5.w),
                child: Row(
                  children: [
                    Visibility(
                      //分公司 ，处置人，都可以退回指派
                      visible: controller.entity.alarmLevel != 2 &&!_getBackS(controller.entity.click) &&
                          !(UserManager.getUserCompanyId() == 100 || controller.entity.alarmLevel == 2 && controller.entity.latestDisposalId == UserManager
                              .getUser()
                              ?.id), //橙色报警级分公司没有退回按钮
                      child: Expanded(
                        flex: 1,
                        child: ElevatedButton(
                            style: ElevatedButton.styleFrom(
                              backgroundColor: const Color(0xFFFFECEA),
                              shape: RoundedRectangleBorder(
                                borderRadius: BorderRadius.circular(22.r),
                              ),
                            ),
                            onPressed: controller.back,
                            child: Text(
                              '退回',
                              style: TextStyle(
                                fontSize: 14.sp,
                                color: const Color(0xFFFA6C6D),
                                fontWeight: FontWeight.w400,
                              ),
                            )),
                      ),
                    ),
                    AppGaps.hGap10,
                    Expanded(
                      flex: 2,
                      child: ElevatedButton(
                          style: ElevatedButton.styleFrom(
                            backgroundColor: AppColors.blue_button,
                            shape: RoundedRectangleBorder(
                              borderRadius: BorderRadius.circular(22.r),
                            ),
                          ),
                          onPressed: controller.confirm,
                          child: Text(
                            '确定',
                            style: TextStyle(
                              fontSize: 14.sp,
                              color: Colors.white,
                              fontWeight: FontWeight.w400,
                            ),
                          )),
                    ),
                  ],
                ),
              )
            ],
          ),
        ),
      ],
    );
  }

  /// 获取字段显示
  Widget _getTextView({required String title, required String value}) {
    return Column(
      crossAxisAlignment: CrossAxisAlignment.start,
      children: [
        Row(
          crossAxisAlignment: CrossAxisAlignment.start,
          children: [
            Text(
              title,
              style: TextStyle(
                fontSize: 14.sp,
                height: 1.2,
                fontWeight: FontWeight.w400,
                color: const Color(0xffC7CEE5),
              ),
            ),
            AppGaps.hGap6,
            Expanded(
                child: Text(
                  value,
                  style: TextStyle(
                    fontSize: 14.sp,
                    height: 1.2,
                    fontWeight: FontWeight.w400,
                    color: const Color(0xff1D3452),
                  ),
                ))
          ],
        ),
        AppGaps.vGap10,
      ],
    );
  }

  Widget _getStateView() {
    return Obx(() {
      return Container(
        padding: EdgeInsets.symmetric(horizontal: 45.w),
        height: 64.w,
        child: Stack(
          alignment: Alignment.center,
          children: [
            Positioned(
              left: 0,
              child: Stack(
                alignment: Alignment.center,
                children: [
                  SvgPicture.asset(
                    controller.currentIndex.value == 0 ? 'assets/svg/icon_normal.svg' : 'assets/svg/icon_un_normal.svg',
                    width: 143.w,
                    height: 40.w,
                  ),
                  Text(
                    '基本信息',
                    style: TextStyle(
                      fontSize: 14.sp,
                      color: controller.currentIndex.value == 0 ? const Color(0xFFffffff) : const Color(0xFF9FA5B0),
                    ),
                  )
                ],
              ).clickOnce(() {
                controller.selectTitle(0);
              }),
            ),
            Positioned(
              right: 0,
              child: Stack(
                alignment: Alignment.center,
                children: [
                  SvgPicture.asset(
                    controller.currentIndex.value == 1 ? 'assets/svg/icon_existence.svg' : 'assets/svg/icon_un_existence.svg',
                    width: 143.w,
                    height: 40.w,
                  ),
                  Text(
                    // !_getBackS(controller.entity.click)?  '处置':'验收',
                    controller.tabStr(),
                    style: TextStyle(
                      fontSize: 14.sp,
                      color: controller.currentIndex.value == 1 ? const Color(0xFFffffff) : const Color(0xFF9FA5B0),
                    ),
                  )
                ],
              ).clickOnce(() {
                controller.selectTitle(1);
              }),
            ),
          ],
        ),
      );
    });
  }



  Widget _showView() {
    switch (controller.entity.click) {
      case 1: //总公司指派
        return Column(children: [
          CustomSelectPage(
            isEnabled: false,
            selectText: UserManager.getUser()!.nickname,
            title: '指派人：',
            onCallBack: () {},
          ),
          CustomSelectPage(
            selectText: controller.latestDistributionIdName,
            title: '所属公司：',
            onCallBack: () {
              controller.selectCurrentDept();
            },
          ),
          CustomSelectPage(
            selectText: controller.affiliateCompanyAssignHighIdName,
            title: '负责人：',
            onCallBack: () {
              //先选公司
              if(controller.latestDistributionIdName.isEmpty){
                AppToast.show('请先选所属公司');
                return;
              }
              Get.toNamed(Routes.yjsystemuserpeopleselectionselectionpage, arguments: {
                'isRadio': true,
                'companyId': controller.latestDistributionId,
              })?.then((value) {
                final List<SystemUserPageEntity> selectedList = value as List<SystemUserPageEntity>;
                controller.affiliateCompanyAssignHighId = selectedList[0].id; //获取人员id
                controller.affiliateCompanyAssignHighIdName = selectedList[0].nickname!; //获取人员名字
                // controller.latestDistributionId = selectedList[0].deptId!; //
                // controller.latestDistributionIdName = selectedList[0].deptName!; //
                controller.update();
              });
            },
          ),

        ]);
      case 2: //总公司再次指派
        return Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
          //退回原因
          const Text('重新指派'),
          CustomSelectPage(
            isEnabled: false,
            selectText: UserManager.getUser()!.nickname,
            title: '指派人：',
            onCallBack: () {},
          ),
          CustomSelectPage(
            selectText: controller.latestDistributionIdName,
            title: '所属公司：',
            onCallBack: () {
              controller.selectCurrentDept();
            },
          ),
          CustomSelectPage(
            selectText: controller.affiliateCompanyAssignHighIdName,
            title: '负责人：',
            onCallBack: () {
              if(controller.latestDistributionIdName.isEmpty){
                AppToast.show('请先选所属公司');
                return;
              }
              Get.toNamed(Routes.yjsystemuserpeopleselectionselectionpage, arguments: {
                'isRadio': true,
                'companyId':controller.latestDistributionId,
              })?.then((value) {
                final List<SystemUserPageEntity> selectedList = value as List<SystemUserPageEntity>;
                controller.affiliateCompanyAssignHighId = selectedList[0].id; //获取人员id
                controller.affiliateCompanyAssignHighIdName = selectedList[0].nickname!; //获取人员名字
                // controller.latestDistributionId = selectedList[0].deptId!; //
                // controller.latestDistributionIdName = selectedList[0].deptName!; //
                controller.update();
              });
            },
          ),

        ]);
      case 3: //分公司指派
        return Column(children: [
          CustomSelectPage(
            isEnabled: false,
            selectText: UserManager.getUser()!.nickname,
            title: '指派人：',
            onCallBack: () {},
          ),
          CustomSelectPage(
            selectText: controller.affiliateCompanyAssignHighIdName,
            title: '负责人：',
            onCallBack: () {
              Get.toNamed(Routes.systemUserPeopleSelectionSelectionPage, arguments: {
                'isRadio': true,
              })?.then((value) {
                final List<SystemUserPageEntity> selectedList = value as List<SystemUserPageEntity>;
                controller.affiliateCompanyAssignHighId = selectedList[0].id; //获取人员id
                controller.affiliateCompanyAssignHighIdName = selectedList[0].nickname!; //获取人员名字
                controller.update();
              });
            },
          ),
        ]);
      case 4: //分公司再次指派
        return Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
          const Text('重新指派'),
          CustomSelectPage(
            isEnabled: false,
            selectText: UserManager.getUser()!.nickname,
            title: '指派人：',
            onCallBack: () {},
          ),
          CustomSelectPage(
            selectText: controller.affiliateCompanyAssignHighIdName,
            title: '负责人：',
            onCallBack: () {
              Get.toNamed(Routes.systemUserPeopleSelectionSelectionPage, arguments: {
                'isRadio': true,
              })?.then((value) {
                final List<SystemUserPageEntity> selectedList = value as List<SystemUserPageEntity>;
                controller.affiliateCompanyAssignHighId = selectedList[0].id; //获取人员id
                controller.affiliateCompanyAssignHighIdName = selectedList[0].nickname!; //获取人员名字
                controller.update();
              });
            },
          ),
        ]);
      case 5: //处置
        return _chuZhi();
      case 6: //再次处置
        return Column(crossAxisAlignment: CrossAxisAlignment.start, children: [const Text('再次处置'), _chuZhi()]);
      case 7: //分公司验收
        return Column(children: [
          Row(
            children: [
              Text(
                '处置结果',
                style: TextStyle(color: const Color(0xFF1D3452), fontSize: 14.sp),
              ),
              _checkBox(
                  choice1Text: '处置合格',
                  choice2Text: '处置不合格',
                  initialChoice1: controller.disposalResults == 0 ? true : false,
                  initialChoice2: controller.disposalResults == 1 ? true : false,
                  click: 7),
            ],
          ),
          CustomHighInputPage(
              isRequired: false,
              title: '说明：',
              text: controller.acceptanceInstructions,
              hintText: '请输入说明',
              onCallBack: (value) {
                controller.acceptanceInstructions = value;
              }),
        ]);
      case 8: //分公司再次验收
        return Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
          const Text('分公司再次验收'),
          Row(
            children: [
              Text(
                '处置结果',
                style: TextStyle(color: const Color(0xFF1D3452), fontSize: 14.sp),
              ),
              _checkBox(
                  choice1Text: '处置合格',
                  choice2Text: '处置不合格',
                  initialChoice1: controller.disposalResults == 0 ? true : false,
                  initialChoice2: controller.disposalResults == 1 ? true : false,
                  click: 8),
            ],
          ),
          CustomHighInputPage(
              isRequired: false,
              title: '说明：',
              text: controller.acceptanceInstructions,
              hintText: '请输入说明',
              onCallBack: (value) {
                controller.acceptanceInstructions = value;
              }),
        ]);
      case 9: //总公司验收
        return Column(children: [
          Row(
            children: [
              Text(
                '处置结果',
                style: TextStyle(color: const Color(0xFF1D3452), fontSize: 14.sp),
              ),
              _checkBox(choice1Text: '处置合格',
                  choice2Text: '处置不合格',
                  initialChoice1: 1 == 1 ? true : false,
                  initialChoice2: 1 == 0 ? true : false,
                  click: 9,
                  isZhong: true),
            ],
          ),
          CustomHighInputPage(
              isRequired: false,
              title: '说明：',
              text: controller.acceptanceInstructions,
              hintText: '请输入说明',
              onCallBack: (value) {
                controller.acceptanceInstructions = value;
              }),
        ]);
      case 10: //总公司再次验收
        return Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
          const Text('总公司再次验收'),
          Row(
            children: [
              Text(
                '处置结果',
                style: TextStyle(color: const Color(0xFF1D3452), fontSize: 14.sp),
              ),
              _checkBox(choice1Text: '处置合格',
                  choice2Text: '处置不合格',
                  initialChoice1: 1 == 1 ? true : false,
                  initialChoice2: 1 == 0 ? true : false,
                  click: 10,
                  isZhong: true),
            ],
          ),
          CustomHighInputPage(
              isRequired: false,
              title: '说明：',
              text: controller.acceptanceInstructions,
              hintText: '请输入说明',
              onCallBack: (value) {
                controller.acceptanceInstructions = value;
              }),
        ]);
    }
    return Container();
  }

  /// 2个复选框
  Widget _checkBox({
    String choice1Text = '选项1',
    String choice2Text = '选项2',
    bool initialChoice1 = false,
    bool initialChoice2 = false,
    int click = 0,
    bool isZhong = false,
  }) {
    return Container(
      margin: EdgeInsets.only(left: 20.w),
      child: CustomTwoChoiceCheckbox(
        choice1Text: choice1Text,
        choice2Text: choice2Text,
        choice1TextColor: TextStyle(
          fontSize: 14.sp,
          fontWeight: FontWeight.w400,
          color: const Color(0xFF8D95A3),
        ),
        choice2TextColor: TextStyle(
          fontSize: 14.sp,
          fontWeight: FontWeight.w400,
          color: const Color(0xFF8D95A3),
        ),
        initialChoice1: initialChoice1,
        initialChoice2: initialChoice2,
        onChoice1Changed: (value) {
          controller.select(value, click, isZhong);
        },
        onChoice2Changed: (value) {
          controller.select(value, click, isZhong);
        },
        checkboxBuilder: (isSelected, onChanged) {
          return CustomCheckbox(
            isChecked: isSelected,
            onChanged: (bool? newValue) => onChanged(),
          );
        },
      ),
    );
  }

  Widget _chuZhi() {
    return Column(
      children: [
        CustomInputPage(
          title: '${CustomDateType.getDataType(controller.entity.dataType)}原因：',
          text: controller.reasonAlarm,
          hintText: '请输入原因',
          onCallBack: (value) {
            controller.reasonAlarm = value;
          },
        ),
        CustomHighInputPage(
            title:'${CustomDateType.getDataType(controller.entity.dataType)}描述：',
            text: controller.alarmDescription,
            hintText: '请输入描述',
            onCallBack: (value) {
              controller.alarmDescription = value;
            }),
        CustomSelectPage(
          selectText: controller.onSiteHandlerName,
          title: '现场处理人：',
          onCallBack: () {
            Get.toNamed(Routes.systemUserPeopleSelectionSelectionPage, arguments: {
              'isRadio': true,
            })?.then((value) {
              final List<SystemUserPageEntity> selectedList = value as List<SystemUserPageEntity>;
              controller.onSiteHandlerId = selectedList[0].id; //获取人员id
              controller.onSiteHandlerName = selectedList[0].nickname!; //获取人员名字
              controller.departmentBelongsId = selectedList[0].deptId!; //部门id
              controller.departmentBelongsIdName = selectedList[0].deptName!; //部门
              controller.update();
            });
          },
        ),
        CustomSelectPage(
          isEnabled: false,
          selectText: controller.departmentBelongsIdName,
          title: '所属部门：',
          onCallBack: () {},
        ),
        CustomSelectPage(
            selectText: controller.onSiteProcessingTime,
            title: '现场处理时间：',
            onCallBack: () {
              controller.showDatePicker();
            }),
        CustomSelectPage(
          isEnabled: false,
          selectText: UserManager.getUser()!.nickname,
          title: '负责人：',
          onCallBack: () {},
        ),
        CustomHighInputPage(
            title: '处置措施：',
            text: controller.disposalMeasures,
            hintText: '请输入处置措施',
            onCallBack: (value) {
              controller.disposalMeasures = value;
            }),
        CustomFileUploadPage(
          type: FileType.custom,
          isShowDivider: false,
          splitCommaInUrl: true,
          isRequired: DartDefines.appInstallChannel == AppInstallChannel.kaifa ?false:true,
          // uploadedFiles: [],
          title: '处置附件',
          onCallBack: (value) {
            final String imgUrl = value.join(',');
            controller.disposalAttachments = imgUrl;
          },
        ),
        // CustomPickerPhoto(
        //   title: '照片:',
        //   maxCount: 9,
        //   imagesList: [],
        // ),
      ],
    );
  }

  ///获取处置合格不
  ///操作类型(
  ///1.总公司派发
  ///2.分公司派发
  ///3,分公司退回
  ///4,总公司验收通过
  ///5,分公司验收通过
  ///6,总公司不通过
  ///7,分公司不通过
  ///8,处置接受
  ///9.处置退回
  ///)
  String _actionType(int actionType) {
    switch (actionType) {
      case 5:
        return '分公司处置合格';
      case 7:
        return '分公司处置不合格';
      case 4:
        return '总公司处置合格';
      case 6:
        return '总公司处置不合格';
      case 3:
        return '分公司';
      case 9:
        return '处置';
      default:
        return '';
    }
  }

  Color _actionTypeC(int actionType) {
    switch (actionType) {
      case 5:
      case 4:
        return const Color(0xFF17D484);
      case 7:
      case 6:
        return const Color(0xFFFA6C6D);
      default:
        return const Color(0xFFFA6C6D);
    }
  }

  bool _getBackS(int click) {
    if (click == 7 || click == 8) {
      //分公司验收
      return true;
    } else if (click == 9 || click == 10) {
      //总公司验收
      return true;
    } else {
      return false;
    }
  }



}